package com.autoMobile.servlet;

import com.autoMobile.dao.VehicleDao;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DeletePositionServlet", value = "/Veh/DeleteVehServlet")
public class DeletePositionServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int id = Integer.parseInt(request.getParameter("id"));
        int success = VehicleDao.deleteVehicle(id);
        HttpSession session = request.getSession();
        if (success != 0) session.setAttribute("message", "删除成功");
         else session.setAttribute("message", "删除失败");
        request.getRequestDispatcher("/Veh/VehListServlet").forward(request, response);
    }
}
